import { isPhoneNumber } from '@/utils/index'
import { status } from 'nprogress';

export const formRules = {
  carNo: [{ required: true, validator: notEmpty, msg: '请输入车牌号', trigger: ['blur', 'change'] }],
  labelTypeName: [{ required: true, validator: notEmpty, msg: '请输入厂牌型号', trigger: ['blur', 'change'] }],
  carBrand: [{ required: true, validator: notEmpty, msg: '车辆品牌', trigger: ['blur', 'change'] }],
  maxOccupants: [{ required: true, validator: notEmpty, msg: '核定乘员人数', trigger: ['blur', 'change'] }],
  isNewEnergy: [{ required: true, validator: notEmpty, msg: '请选择是否是新能源', trigger: ['blur', 'change'] }],
  cardType: [{ required: true, validator: notEmpty, msg: '请选择车型', trigger: ['blur', 'change'] }],
  runId: [{ required: true, validator: notEmpty, msg: '请选择运行状态', trigger: ['blur', 'change'] }],
  operateId: [{ required: true, validator: notEmpty, msg: '请选择运营状态', trigger: ['blur', 'change'] }],
  departmentId: [{ required: true, validator: notEmpty, msg: '请选择编制部门', trigger: ['blur', 'change'] }],
}



// 校验不能为空
function notEmpty(rule, value, callback) {
  if (!value) {
    if(rule.field === 'status' && value === 0){
      return callback()
    }
    return callback(new Error(rule.msg))
  }else{
    if(rule.field === 'attachment' && (!value || value.length === 0)){
      return callback(new Error(rule.msg))
    }
    return callback()
  }
}



export const runList = [
  {name: '使用', id: 1},
  {name: '停用', id: 2},
  {name: '闲置', id: 3},
  {name: '已交易', id: 4},
]

export const operateList = [
  {name: '可使用', id: 1},
  {name: '故障', id: 2},
  {name: '维护', id: 3},
]

export const typeList = [
  {name: '驾驶', id: 1},
  {name: '故障', id: 2},
  {name: '维护', id: 3},
  {name: '交易', id: 4},
]